package cn.caskm.souvenirshopsystem.controller.api;

import cn.caskm.souvenirshopsystem.domain.Result;
import cn.caskm.souvenirshopsystem.domain.dto.PageDTO;
import cn.caskm.souvenirshopsystem.domain.query.AnnouncementQuery;
import cn.caskm.souvenirshopsystem.domain.vo.AnnouncementVO;
import cn.caskm.souvenirshopsystem.service.AnnouncementService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/announcement")
@RequiredArgsConstructor
public class AnnouncementController {

    private final AnnouncementService announcementService;

    @GetMapping("/page")
    public Result<PageDTO<AnnouncementVO>> page(AnnouncementQuery query) {
        // 前台只显示已发布的公告
        query.setStatus("1");
        return announcementService.page(query);
    }

    @GetMapping("/detail/{announcementId}")
    public Result<AnnouncementVO> detail(@PathVariable("announcementId") Integer announcementId) {
        return announcementService.detail(announcementId);
    }

}
